// =====================================================================================
//	Copyright (C) 2019 by Jiaxing Shao.All rights reserved.
//	文 件 名:  main.cpp
//	作    者:  Jiaxing Shao, 13315567369@163.com
//	版 本 号:  1.0
//	创建时间:  2019年05月06日 18时14分02秒
//	Compiler:  g++
//	描    述:
// =====================================================================================

#include <iostream>
using namespace std;

#include "websocket_server.h"

#include <pthread.h>
#include <stdlib.h>

WebSocketServer websocket;

void *test_func(void *arg);

int main(int argc, char *argv[])
{
    int       port = 10086;
    pthread_t pid;
    pthread_create(&pid, NULL, test_func, NULL);
    websocket.start(port);
    return EXIT_SUCCESS;
}

void *test_func(void *arg)
{
    char buffer[] = "Hello,world!";
    int  length   = strlen(buffer);
    while (true) {
        websocket.send_message(buffer, length);
        sleep(0.01);
    }
}
